package logic

import (
	"context"
	"errors"
	"user_srv/models/mysql"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseShowLogic) HouseShow(in *user.HouseShowRequest) (*user.HouseShowResponse, error) {
	// todo: add your logic here and delete this line
	house := mysql.House{}
	err := house.HouseView(in.HouseId)
	if err != nil {
		logx.Info("房源详情信息不存在")
		return nil, errors.New("房源详情信息不存在")
	}
	return &user.HouseShowResponse{
		HouseId:       int64(house.ID),
		HouseName:     house.HouseName,
		HouseFloor:    house.HouseFloor,
		HouseType:     house.HouseType,
		Address:       house.Address,
		HouseCover:    house.HouseCover,
		Area:          house.Area,
		Price:         house.Price,
		HouseDescribe: house.HouseDescribe,
		HouseStatus:   house.HouseStatus,
	}, nil
}
